package Decorator;

public class TestDecorator {
    public static void main(String[] args){
        BaseObject object1 = new ConcreteDecorator1(
                new ConcreteDecorator2(
                        new ConcreteObject1()
                )
        );
        BaseObject object2 = new ConcreteDecorator2(
                new ConcreteDecorator1(
                        new ConcreteObject2()
                )
        );
        System.out.println(object1.getInfo());
        System.out.println(object2.getInfo());
    }
}

abstract class BaseObject{
    String info = "baseObject";

    public abstract String getInfo();
}

class ConcreteObject1 extends BaseObject{
    @Override
    public String getInfo() {
        return "ConcreteObject1 ";
    }
}

class ConcreteObject2 extends BaseObject{
    @Override
    public String getInfo() {
        return "ConcreteObject2 ";
    }
}

abstract class AbstractDecorator extends BaseObject{
    public abstract String getInfo();
}

class ConcreteDecorator1 extends AbstractDecorator{
    BaseObject object;
    public ConcreteDecorator1(BaseObject object){
        this.object = object;
    }
    @Override
    public String getInfo() {
        return this.object.getInfo() + "ConcreteDecorator1 ";
    }
}

class ConcreteDecorator2 extends AbstractDecorator{
    BaseObject object;
    public ConcreteDecorator2(BaseObject object){
        this.object = object;
    }
    @Override
    public String getInfo() {
        return this.object.getInfo() + "ConcreteDecorator2 ";
    }
}